import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserGroupVO, UserGroupForm, UserGroupQuery } from '@/api/access/user/user-group/types';

/**
 * 查询人员群组列表
 * @param query
 * @returns {*}
 */

export const listUserGroup = (query?: UserGroupQuery): AxiosPromise<UserGroupVO[]> => {
  return request({
    url: '/user/user-group/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询人员群组详细
 * @param userGroupId
 */
export const getUserGroup = (userGroupId: string | number): AxiosPromise<UserGroupVO> => {
  return request({
    url: '/user/user-group/' + userGroupId,
    method: 'get'
  });
};

/**
 * 新增人员群组
 * @param data
 */
export const addUserGroup = (data: UserGroupForm) => {
  return request({
    url: '/user/user-group',
    method: 'post',
    data: data
  });
};
/**
 * 新增人员群组 电梯关联
 * @param data
 */
export const addElevator = (data: UserGroupForm) => {
  return request({
    url: '/user/groupElevator',
    method: 'post',
    data: data
  });
};
/**
 * 新增人员群组 门禁关联
 * @param data
 */
export const addAccessControl = (data) => {
  return request({
    url: '/user/groupAccessControl',
    method: 'post',
    data: data
  });
};

/**
 * 修改人员群组
 * @param data
 */
export const updateUserGroup = (data: UserGroupForm) => {
  return request({
    url: '/user/user-group',
    method: 'put',
    data: data
  });
};

/**
 * 删除人员群组
 * @param userGroupId
 */
export const delUserGroup = (userGroupId: string | number | Array<string | number>) => {
  return request({
    url: '/user/user-group/' + userGroupId,
    method: 'delete'
  });
};
